home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 001-025 / disk_003 / cforth / common.h < prev    next >
Text File  |  1992-05-06  |  5KB  |  126 lines

  1. /*
  2.  * This is common.h -- the defines which are common to both nf.c and forth.c.
  3.  * These include the name of the SAVEFILE (the file which nf.c creates,
  4.  * and the default image which f.c loads), and all those boundaries for
  5.  * memory areas, like UP, USER_DEFAULTS, etc.
  6.  */
  7.  
  8. /*
  9.  * NOTE THAT THIS FORTH IMPLENTATION REQUIRES int TO BE TWICE THE SIZE OF short
  10.  */
  11.  
  12. #define TRUE 1
  13. #define FALSE 0
  14.  
  15. /*
  16.    TWEAKING: define TRACE to allow tracing, BREAKPOINT to allow breakpoints.
  17.    Each of these takes up time in the inner interpreter, so if you are
  18.    not debugging, take them out. Without TRACE, the DOTRACE primitive will
  19.    still work, but the TRON primitive will have no effect.
  20. */
  21.  
  22. #define TRACE
  23. #define BREAKPOINT
  24.  
  25. /* external files */
  26.  
  27. #define COREFILE "forth.core"    /* used for input to f.c, output from nf.c */
  28. #define DICTFILE "forth.dict"    /* used for input to nf.c */
  29. #define MAPFILE "forth.map"    /* used for dump-output from nf.c */
  30. #define DUMPFILE "forth.dump"    /* used for dump-output from f.c */
  31. #define BLOCKFILE "forth.block"    /* used for block i/o */
  32. #define SAVEFILE "forth.newcore"    /* used by (SAVE) primitive */
  33.  
  34. /* MEMORY ALLOCATION CONSTANTS */
  35.  
  36. /* Set INITMEM to the size of the largest FORTH model you want nf to create.
  37.    This can be just barely enough (within GULPFRQ words) to hold the initial 
  38.    FORTH image, or it can be the maximum size you will ever want. Somewhere in
  39.    between is best, so you don't fragment memory with realloc() calls right
  40.    away. */
  41.  
  42. #define INITMEM (13*1024)    /* 13K holds the distribution forth.dict */
  43.   
  44. /* set MAXMEM to the MOST MEMORY YOU EVER WANT ALLOCATED TO FORTH. FORTH will
  45.    never allocate more than MAXMEM*sizeof(short) for the FORTH memory image.
  46.    Note that other functions, like open, read, and write, allocate memory
  47.    transparent to the forth system. MAXMEM will not affect these. Also,
  48.    note that realloc is used to grow the FORTH image, and LARGE CHUNKS of
  49.    fragmented memory can result. If you want to keep a tight rein on things,
  50.    set MAXMEM to the same number as INITMEM, and the FORTH memory image will
  51.    be fixed at that many SHORTs, with no later allocations, and therefore
  52.    no fragmenting.
  53.     A value of 0 for MAXMEM means "allocate as much as you want" -- 
  54.    useful on virtual-memory machines. Also note that each malloc and realloc
  55.    is checked for success (of course), so MAXMEM is truly a maximal limit.
  56.     NOTE THAT MODELS OF GREATER THAN 32K MAY CRASH BECAUSE OF SIGNED
  57.    VALUES. THIS HAS NOT BEEN ADEQUATELY TESTED.
  58. */
  59.  
  60. #define MAXMEM 0
  61.  
  62. /* set NSCR to the number of disk blocks from you want to keep in FORTH memory
  63.    at any time. If your disks are fast enough, you might want a low number
  64.    like 3. If you have lots of memory, you might want something like 10.
  65.    In any case, this number MUST BE AT LEAST 2. */
  66.  
  67. #define NSCR 5    /* MUST BE AT LEAST 2 */
  68.  
  69. /* end of implementation-dependent DEFINEs. */
  70.  
  71. /* define bits for the first byte of each word */
  72. #define MSB 0x80        /* says this is first byte */
  73. #define IMMEDIATE 0x40        /* Says this word is immediate */
  74. #define SMUDGE 0x20        /* on = you can't find this word */
  75.  
  76. #define MAXWIDTH 0x20        /* Maximum length of a word */
  77.  
  78. #define KBBUFF 1024        /* one disk-quantum */
  79. #define US 32            /* words needed for user variables */
  80. #define CO (KBBUFF+4)
  81.                 /* size of a disk buffer w/4 words overhead */
  82. #define NBUF NSCR        /* number of disk buffers, at 1 to a screen */
  83.  
  84. /* Memory Management boundaries -- each name refers to the FIRST location of
  85.    the indicated field Some fields are nested, and I have tried to show the
  86.    nesting nature in the defines. */
  87.  
  88. #define ORIGIN 0        /* the Origin of this system is zero */
  89. #define ORIG ORIGIN        /* another word for ORIGIN */
  90. #define SCRATCHSIZE 16        /* From ORIGIN to ORIGIN+SCRATCHSIZE is scratch
  91.                    space which is saved across saves: see the
  92.                    definition of this space below */
  93. #define USER_DEFAULTS (ORIGIN+SCRATCHSIZE)    /* 16 */
  94.                 /* start of user variable initial-values space
  95.                    -- it's DEFS-SIZE bytes long */
  96. #define DEFS_SIZE 8        /* words in the USER DEFAULTS area */
  97. #define UP (USER_DEFAULTS+DEFS_SIZE)    /* User var space, US bytes long */
  98. #define TIB_START (UP+US)    /* Terminal input buffer, same size as a
  99.                    disk buffer (KBBUFF words), starts after
  100.                    user variables */
  101. #define TIB_END (TIB_START + KBBUFF)
  102. #define CS_SIZE 128        /* words in the Computation Stack */
  103. #define RS_SIZE 256        /* words in the Return Stack */
  104. #define INITS0 (TIB_START+KBBUFF+CS_SIZE) /* c. stack grows down CSS words,
  105.                    bangs into end of TIB */
  106. #define INITR0 (INITS0+RS_SIZE)    /* Return stack grows down RSS words, bangs
  107.                    into INITS0. */
  108. #define BUF1 INITR0        /* buffers start right after r. stack */
  109. #define DPBASE (BUF1+(NBUF*CO))    /* Dictionary starts just past last buffer */
  110.  
  111. /* low-core definitions */
  112. #define LIMIT 0            /* mem[LIMIT] tells the size of core */
  113. #define COLDIP 1        /* mem[COLDIP] holds the CFA of ABORT */
  114.         /* you can set ip=mem[COLDIP] and call next() to start */
  115.  
  116. /* these locations define the warm-start machine state: if you save the FORTH
  117.    memory image, then restart it, execution will start up with these values.
  118.    This save/restore system is not implemented, so leave mem[SAVEDIP] = 0. */
  119.  
  120. #define SAVEDIP 2        /* mem[SAVEDIP] = 0 for newly-generated
  121.                    systems, or the IP for a saved system */
  122. #define SAVEDSP 3        /* restored when SAVEDIP != 0 */
  123. #define SAVEDRP 4        /* ditto */
  124.  
  125. #define ABORTIP 5        /* need this to recover from ^C */
  126.